<style>
body {
  min-width:357px;
  overflow-x:hidden;
}

img {
  margin:5px;
  border:2px solid black;
  vertical-align:middle;
  width:75px;
  height:75px;
}

</style>

<script>
var req;
var tabID;

chrome.windows.getCurrent(function(wind)
	{
		chrome.tabs.getSelected(wind.id, function(ta) 
			{
				tabID = ta.id;
				CallServerWithThis(ta.url);	
			}
		);
	}
);

function visualizeResults(Tab){

	
}

function showResult() {
    chrome.tabs.executeScript(null, {file: "test.js"});
    chrome.tabs.insertCSS(tabID, {file : "highlight.css"}, null);

  //var txtNode = document.createTextNode(req.responseText);
  //document.body.appendChild(txtNode);
  
  //var txtJSON;

	jsonMockresult = eval('(' + req.responseText + ')');
	
  for(var i =0 ; i<jsonMockresult.relationships.length;i++)
  {
  	var p1 = jsonMockresult.relationships[i].connection[0];
  	var p2 = jsonMockresult.relationships[i].connection[1];
    chrome.tabs.executeScript(null, {code:"highlightOnLoad('" +p1 + "|"+p2 +"');"});
	//txtJSON = document.createTextNode(jsonMockresult.relationships[i].connection);
	//document.body.appendChild(txtJSON);
  }
  
    
    
  //chrome.tabs.getSelected(windowId, visualizeResults);


}


function CallServerWithThis(url)
{
	//var server_url = "http://127.0.0.1:8888/gfb?articleurl=" + url;
	var server_url = "http://lightcon2010.appspot.com/gfb?articleurl=" + url;
	req = new XMLHttpRequest();
	req.open(
		"GET",
		server_url,
		true);
	req.onload = showResult;
	req.send(null);
}
</script>